package common;
import java.util.ArrayList;
import java.util.Random;

public class NoRepeatRandom
{
	private ArrayList<Integer> numList;
	private Random rand;

	public NoRepeatRandom()
	{
		numList = new ArrayList<Integer>();
		rand = new Random();
	}

	public int getNextInt(int max) throws Exception
	{
		if (numList.size() == max)
			throw new Exception("No more number");

		int temp;

		do
		{
			temp = rand.nextInt(max);
		} while (numList.contains(temp));
		
		numList.add(temp);
		return temp;
	}
}